package my.study.java.util.Calendar;

import java.util.Calendar;
import java.util.Date;

public class CalendarExample1 {

	/**
	 * set roll add的区别
	 * @param args
	 */
	public static void main(String[] args) {
		Calendar calendar = Calendar.getInstance();
		Date date = calendar.getTime();
		p(calendar.toString());
		p(date);
		calendar.add(Calendar.HOUR, 1);
		p(calendar.getTime());
		calendar.set(Calendar.HOUR, 1);
		p(calendar.getTime());
		calendar.setLenient(true);
		calendar.add(Calendar.HOUR_OF_DAY, 30);
		p(calendar.getTime());
		calendar.roll(Calendar.HOUR_OF_DAY, 24);
		p(calendar.getTime());
		calendar.roll(Calendar.HOUR_OF_DAY, -24);
		p(calendar.getTime());
		calendar.add(Calendar.HOUR_OF_DAY, -24);
		p(calendar.getTime());
	}
	private static void p(Object o) {
		System.out.println(o);
	}
}
